package com.gopay.scheduler.service.cacert.impl;

import com.gopay.common.domain.cert.MsgGopaySignCert;
import com.gopay.common.security.apicert.dao.MsgGopaySignCertQueryDAO;
import com.gopay.scheduler.dao.MsgGopaySignCertDAO;
import com.gopay.scheduler.service.cacert.MsgGopaySignCertService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * description ：国付宝服务器证书接口实现
 * edit by ：lx
 * datetime ：2017/11/23 16:41
 */
@Service("msgGopaySignCertService")
public class MsgGopaySignCertServiceImpl implements MsgGopaySignCertService {

    @Resource(name = "msgGopaySignCertQueryDAO")
    private MsgGopaySignCertQueryDAO msgGopaySignCertQueryDAO;
    @Resource(name = "msgGopaySignCertDAO")
    private MsgGopaySignCertDAO msgGopaySignCertDAO;
    @Override
    public List<MsgGopaySignCert> getDataToEnc() {
        List<MsgGopaySignCert> list;
        String hql = "from MsgGopaySignCert t where 1=1 and t.privateKeyPCI IS NULL ";
        Map<String, Object> param = new HashMap<>();
        list = msgGopaySignCertQueryDAO.findByHql(hql,param);
        return list;
    }

    @Override
    public void updateEncData(MsgGopaySignCert msgGopaySignCert) {
        msgGopaySignCertDAO.update(msgGopaySignCert);
    }
}
